﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using CanDichVu.Db;
using CanDichVu.Service.Iservice;
using CanDichVu.FrameWork.Conrtron;
using CanDichVu.FrameWork.Helper;

namespace CanDichVU.Controllers
{
    public class CateController : ContronllerBase
    {

       private readonly ICate _icate;
        private readonly ITinhThanh _ITinhThanh;
        private readonly IQuanHuyen _IQuanHuyen;
        private readonly IPost _IPost;
        private readonly CanDichVu.FrameWork.Helper.HtmlHelper _ihtml = new CanDichVu.FrameWork.Helper.HtmlHelper();
        private readonly HtmlRemoval _ihtmlRemove = new HtmlRemoval();
        private readonly IUser _IUser;

        public CateController(ICate icate, ITinhThanh iTinhThanh, IQuanHuyen iQuanHuyen, IPost iPost, IUser iUser)
        {
            this._icate = icate;
            this._IQuanHuyen = iQuanHuyen;
            this._ITinhThanh = iTinhThanh;
            this._IPost = iPost;
            this._IUser = iUser;
        }


        //
        // GET: /Cate/

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult CateDVDetails(int cateid, string name, int? page)
        {
            var entity = _icate.GetById(cateid);
            if (page == null)
            {
                page = 1;
            }
            ViewBag.PageCurr = page;
            return View("cateDetails",entity);
        }

        public ActionResult ListPostOnCate(int cate, int take, int skip)
        {
            if (skip == 0) skip = 1;
            var listPost = _IPost.GetListOnCate(cate, false, true,take, skip);
            return PartialView("_ListPostOnCate", listPost);
        }

        public ActionResult ListPostOnCateProvince(int cate, int take, int skip)
        {
            if (skip == 0) skip = 1;
            var listPost = _IPost.GetListOnCate(cate, false, true, take, skip);
            return PartialView("_ListPostOnCateProvince", listPost);
        }

        public ActionResult GetCateLoadOnHome(int parentId)
        {
            var _List = _icate.getListByParent(parentId);
            return PartialView("_GetCateChildLoadOnHome", _List);
        }

    }
}
